package bancodedados;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public abstract class ResultSetDataFetcher<T extends Object> {
	
	protected ArrayList<T>	results	= new ArrayList<T>();
	protected static final String	SELECT	= " SELECT ";
	protected static final String	FROM	= " FROM ";
	protected static final String	WHERE	= " WHERE ";
	protected static final String	GROUPBY	= " GROUP BY ";
	protected static final String	ORDERBY	= " ORDER BY ";
	protected static final String	LIMIT	= " LIMIT ";
	protected static final String	OFFSET	= " OFFSET ";

	public ResultSetDataFetcher() {
		super();
	}

	public abstract void fetchDataFromResultSet(ResultSet resultSet) throws SQLException;

	public final ArrayList<T> getFetchedData() {
		return results;
	}

	public final T getFirstResult() {
		if (results.size() !=0){
			return results.get(0);
		}else {
			return null;
		}
	}

	public final boolean hasResults() {
		return results.size()>0;
	}

	public abstract String getSelectionString();
	
}